package com.example.controller;

import com.example.mapper.DepartmentMapper;
import com.example.pojo.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//RestController = @Controller + @ResponseBody
@RestController
public class DepartmentController {

    @Autowired
    private DepartmentMapper departmentMapper;
    // 查询全部部门
    @GetMapping("/getAll")
    public List<Department> getDepartments(){
        return departmentMapper.getAllDepartments();
    }

    //根据id查询部门信息
    @GetMapping("/getDept/{id}")
    public Department getDepartmentById(@PathVariable("id") Integer id){
        return departmentMapper.getDepartmentById(id);
    }
}
